<?php
/**
 * Opcion de RadioButton
 */
class RadioButtonOption {
    
    private $value;
    private $label;
    private $selected;
    private $id;
    
    public function __construct($label,$value,$selected = FALSE) {
        
        $this->label = $label;
        $this->value = $value;
        $this->selected = $selected;
    }
    
    public function __toString() {
        return $this->_generateHtml();
    }
    
    private function _generateHtml() {
        $params = '';
        if($this->selected) $params = $params . 'selected="true" ';
        $html = array();
        $html[] = '<input type="radio" name="'.$this->id.'" value="'.$this->value.'" '.$params.'>';
        $html[] = $this->label;
        $output = '&nbsp;';
        foreach ($html as $code) {
            $output = $output.$code;
        }
        return $output;
    }
    
    public function getValue() {
        return $this->value;
    }

    public function setValue($value) {
        $this->value = $value;
    }

    public function getLabel() {
        return $this->label;
    }

    public function setLabel($label) {
        $this->label = $label;
    }

    public function getSelected() {
        return $this->selected;
    }

    public function setSelected($selected) {
        $this->selected = $selected;
    }
    
    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

}

?>
